﻿
using Dapper;
using hdb;
using hentity;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
namespace hwms {
    //一个任务完成则不允许执行删除任务
    public class WcsDeleteTaskEngine :GkTransaction {
         public long paramId;
        protected CoreTask ct;
   
        protected CoreTaskParam param;
        //入库完成反馈
        protected override TransRes Execute(IDbConnection conn, IDbTransaction tran)
        {
            param =  conn.GetById<CoreTaskParam>(paramId,tran);
            ct = TaskPersistenceUtil.getCoreTask(conn, tran, param.taskId);

            //check(cs, coreTaskParam);
            StockUtil.taskDeleteUpdateStock(conn, tran, ct.stockId,ct.src);
            CsdUtil.taskDeleteUpdateStockDetail(conn, tran, ct);
            exec(conn ,tran ,"update Core_Task set Status=-1, Finsh_Time=sgj_get_sys_now where id=@id " ,ct);
            exec(conn ,tran ,"update Core_Task_Param set Status=-1 where task_Id=@id " ,ct);
            CoreUtil.UpdataWhLoc(conn, tran,param.src ,0);
            CoreUtil.UpdataWhLoc(conn ,tran ,param.des,0 );

            return new TransRes();
        }

        


    }
}
